<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf" %>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="sys.user.title"/></title>
    <meta name="decorator" content="list"/>
    <html:component name="bootstrap-treeview"/>
    <html:css name="iCheck,Validform,jquery-ztree,easy-ui"/>
    <html:js name="iCheck,Validform,jquery-ztree,easy-ui,public-js"/>
    <style type="text/css">.row {
        margin: 0;
    }</style>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="${staticPath}/common/js/window.js"></script>
    <script type="text/javascript" src="${staticPath}/common/js/ztree.js"></script>
</head>
<body title="<spring:message code="sys.user.title" />">
<div class="easyui-layout" fit="true" id="cc" style="width:100%;">
    <div data-options="region:'west',split:true" title="组织机构" style="width:20%;">
        <div class="zTreeDemoBackground left">
            <ul id="treeObj" class="ztree"></ul>
        </div>
    </div>
    <div data-options="region:'center'" title="用户列表">
        <div class="content-padding">
            <grid:grid id="userGridId"
                       url="${adminPath}/sys/syshomepagemanage/ajaxListUserByOrg?type=0&homePageId=${homePageId}">
                <grid:column label="sys.common.key" hidden="true" name="id" width="100"/>
                <grid:query name="orgId" queryMode="hidden"/>
                <grid:column label="sys.user.realname" name="realname" width="60"/>
                <grid:column label="sys.user.username" name="username" width="60"/>
                <grid:column label="sys.user.belonged.org" name="belongedOrg"/>
                <grid:column label="sys.user.organization.name" name="orgName"/>
                <grid:column label="sys.user.email" name="email" width="60"/>
                <grid:column label="sys.user.phone" name="phone" width="60"/>
                <%-- <grid:toolbar  function="search"/>
                 <grid:toolbar  function="reset"/>--%>
            </grid:grid>
        </div>
    </div>
</div>
<script type="text/javascript">
    var treeObj;
    /**
     * @description 设置加载配置.<br>
     * @date 2018/3/29.<br>
     * @author zcg .<br>
     */
    var setting = {
        callback: {
            onClick: onClick
        }
    };

    /**
     * @description 初始化加载js.<br>
     * @date 2018/3/29.<br>
     * @author zcg .<br>
     */
    $(function () {
        var url = '${adminPath}/sys/organization/findOrgTree';
        treeObj = $.ztree('treeObj', url, setting);
    });

    function onClick(event, treeId, treeNode, clickFlag) {
        //$("input[name='orgId']").val(treeNode.id);
        search('userGridIdGrid', {nodeId: treeNode.id});
    }

    var gridId = "userGridIdGrid";

    /*得到选中行的ids*/
    function getUserIds() {
        var ids = $("#" + gridId).jqGrid('getGridParam', 'selarrrow');
        if (ids.length==0) {
            top.layer.msg("请选择要取消关联的用户!", {icon: 0, time: 3000});
        }
        return ids;
    }
</script>
</body>
</html>